#import <Foundation/Foundation.h>
#import <AFNetworking/AFNetworking.h>
#import "MNBaseReq.h"
#import "MNBaseRsp.h"
#import <MJExtension/MJExtension.h>

#define TIMEOUT_INTERVAL    15
#define MNNETWORK           [MNNetwork shareInstance]

typedef void(^successBlock)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseData, MNBaseRsp * _Nullable rsp);
typedef void(^failureBlock)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error);
typedef void(^progressBlock)(NSProgress * _Nonnull downloadProgress);
typedef void (^formDataBlock)(id <AFMultipartFormData> _Nonnull formData);

NS_ASSUME_NONNULL_BEGIN

@interface MNNetwork : NSObject
// 是否打印日志
@property (nonatomic, assign) BOOL enableLog;
// 基础url
@property (nonatomic, strong) NSString *baseUrl;
// 超时时间
@property (nonatomic, assign) NSTimeInterval timeoutInterval;

@property (nonatomic, strong, readonly) AFHTTPSessionManager *sessionManager;

@property (nonatomic, strong) NSMutableDictionary *defaultHeaders;

/// 取消所有请求
- (void)cancelAllRequest;

- (void)request:(MNBaseReq *)req callBack:(void(^)(__kindof MNBaseRsp * _Nonnull rsp))callBack downloadProgress:(nullable progressBlock)downloadProgress uploadProgress:(nullable progressBlock)uploadProgress;
- (void)request:(MNBaseReq *)req callBack:(void(^)(__kindof MNBaseRsp * _Nonnull rsp))callBack;


#pragma mark- 全局配置
+ (instancetype)shareInstance;
- (void)getAccessToken:(nullable void(^)(BOOL success, MNBaseRsp *rsp))complete;
//- (void)log:(NSString *)logStr, ... ;



#pragma mark- ------ 临时 ------
@property (nonatomic, strong, nullable) NSString *accessToken;
@property (nonatomic, strong, nullable) NSString *tokenType;
@end

NS_ASSUME_NONNULL_END
